package cn.itcast.java.exercise;

import java.util.Arrays;
import java.util.Scanner;

/**
 * Author itcast
 * Date 2021/10/9 6:52
 * 模拟三次登录
 */
public class LoginDemo {
    public static void main(String[] args) {
        System.out.println("请输入用户名和密码");
        String username = "admin";
        int password = 123456;

        Scanner scanner = new Scanner(System.in);
        /*for (int i = 0; i < 3; i++) {
            String name = scanner.next();
            int pwd = scanner.nextInt();
            if (name.equals(username) && password == pwd) {
                System.out.println("login success");
                break;
            } else {
                if (2 - i > 0) {
                    System.out.println("录入有误，您还有 " + (2 - i) + " 次登录机会");
                } else {
                    System.out.println("登录失败次数超过最大次数");
                    break;
                }
            }
        }*/
        char[] chars = username.toCharArray();
        String s = Arrays.toString(chars);
        System.out.println(chars);
        System.out.println("字符串： " +s);
        String temp = "";
        for (int i = chars.length-1; i >=0; i--) {
            System.out.println(username.charAt(i));
            temp+=chars[i];
        }

        System.out.println("temp: "+temp);

        String s1 = new StringBuffer(s).reverse().toString();
        System.out.println(s1);

    }
}
